<?php
namespace Admin\Controller;
use Think\Controller;
class CommonController extends Controller {
	//判断用户是否已登录
	public function _initialize () {
		/*
		if (!isset($_SESSION['session_id']) && !isset($_SESSION['session_username'])) {
			$this -> redirect('Login/index');
		}*/	

		if (!isset($_SESSION['session_id']) && !isset($_SESSION['session_username'])) {
			$this -> redirect('Login/index');
		}
		/**
		*	MODULE_NAME 	模块
		*	CONTROLLER_NAME	控制器
		*	ACTION_NAME 	方法
		*/
		$notAuth = in_array(CONTROLLER_NAME, explode(',', C('NOT_AUTH_CONTROLLER'))) ||  in_array(ACTION_NAME, explode(',', C('NOT_AUTH_ACTION')));	
		
		$rbac = new \Org\Util\Rbac(); 
		if(!$rbac::AccessDecision() and !$notAuth){  
			echo '<script type="text/javascript">alert("没有权限！");window.history.back(-1); </script>';  
			die();  
		}  
	}
}